package logic

import (
	"context"
	"shop/shop"

	"houseapi/internal/svc"
	"houseapi/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ReservationAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewReservationAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ReservationAddLogic {
	return &ReservationAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ReservationAddLogic) ReservationAdd(req *types.ReservationAddRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	Reservation, err := l.svcCtx.ShopSrv.ReservationAdd(l.ctx, &shop.ReservationAddRequest{
		UserId:          req.UserId,
		HouseId:         req.HouseId,
		ReservationTime: req.ReservationTime,
	})
	if err != nil {
		return &types.Response{
			Code:    500,
			Message: err.Error(),
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Code:    200,
		Message: "预约成功",
		Data:    Reservation,
	}, nil
}
